#include <dao.h>
#include <btBulletDynamicsCommon.h>

#include "btMotionState.h"
#include "btTransform.h"

static void getWorldTransform(DaoContext *ctx, DValue *p[], int N) {
    btMotionState	*ptr = (btMotionState*) DaoCData_GetData(p[0]->v.cdata);
    btTransform 	trans;
    btTransform 	*res;

    ptr->getWorldTransform(trans);

    res = new btTransform(trans);
    DaoContext_PutCData(ctx, res, &btTransformTyper);
};

static void getWorldTransform2(DaoContext *ctx, DValue *p[], int N) {
    btMotionState	*ptr = (btMotionState*) DaoCData_GetData(p[0]->v.cdata);
    btTransform 	*res = (btTransform*) DaoCData_GetData(p[1]->v.cdata);

    ptr->getWorldTransform(*res);
};

static DaoFuncItem meth[] = {
    { getWorldTransform, 	"getWorldTransform(self:btMotionState) => btTransform" },
    { getWorldTransform2, 	"getWorldTransform(self:btMotionState, trans:btTransform)" },
    { NULL, NULL }
};

DaoTypeBase btMotionStateTyper = {
    "btMotionState",
    NULL,
    NULL,               /* constant */
    meth,       	/* methods */
    { NULL },     	/* parent type */
    { NULL },
    NULL,
    NULL                /* free by free() */
};
